<template>
  <div id="layout">
    <div class="menu">
      <el-radio-group v-model="isCollapse" style="margin-bottom: 20px">
        <el-radio-button :label="false">展开</el-radio-button>
        <el-radio-button :label="true">收起</el-radio-button>
      </el-radio-group>
      <el-menu
        default-active="/book"
        :collapse="isCollapse"
        router>
        <el-menu-item index="/book">
          <i class="el-icon-menu"></i>
          <span slot="title">书籍管理</span>
        </el-menu-item>
        <el-menu-item index="/blog">
          <i class="el-icon-document"></i>
          <span slot="title">博客管理</span>
        </el-menu-item>
        <el-menu-item index="/video">
          <i class="el-icon-document"></i>
          <span slot="title">视频管理</span>
        </el-menu-item>
        <el-menu-item index="/resource">
          <i class="el-icon-setting"></i>
          <span slot="title">资源管理</span>
        </el-menu-item>
        <el-submenu index="">
          <template slot="title">
            <i class="el-icon-location"></i>
            <span slot="title">用户管理</span>
          </template>
          <el-menu-item index="/user">用户列表</el-menu-item>
          <el-menu-item index="" @click="doLogout">注销当前账号</el-menu-item>
        </el-submenu>
      </el-menu>
    </div>
    <div class="container">
      <router-view></router-view>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      // 控制侧边栏是否折叠
      isCollapse: false,
    };
  },
  methods: {
    doLogout() {
      sessionStorage.removeItem("token");
      localStorage.removeItem("token");
      this.$router.push("/login");
    },
  },
};
</script>


<style>
#layout {
  display: flex;
}
#layout .menu {
  width: 200px;
}
.container {
  width: 100%;
}
</style>